import http from '@ohos.net.http';
class Text{
    baseURL:string ='http://10.225.205.54:8086'

    getMessage(): Promise<string> {
       return new Promise((resolve,reject)=>{
           //创建http的请求对象
           let httpRequest=http.createHttp()
           //发送请求
           httpRequest.request(
               `${this.baseURL}/test`,
               {
                   method:http.RequestMethod.GET
               }
           )
               .then(resp=>{
                   if(resp.responseCode===200){
                       console.log('查询成功',resp.result)
                       resolve(resp.result.toString())
                   }else{
                       console.log('查询成功',JSON.stringify(resp))
                       reject('查询失败')
                   }
               })
               .catch(error=>{
                   console.log('查询失败',JSON.stringify(error))
                   reject('查询失败')
               })
       })
    }
}

const text=new Text();
export default text as Text;